<?php
	class Tk_test_topic_historys extends CI_Model{

		function __construct(){
			parent::__construct();
		}

		function get_answer_topic($conditions = array()){
			$where = "WHERE 1=1";
			if($conditions){
				if(!empty($conditions['type'])){
					$where .= " AND type = '{$conditions['type']}'";
				}
				if(!empty($conditions['data_id'])){
					$where .= " AND data_id = '{$conditions['data_id']}'";
				}
				if(!empty($conditions['volume_history_id'])){
					$where .= " AND volume_history_id='{$conditions['volume_history_id']}' ";
				}

				if(!empty($conditions['home_work_history_id'])){
					$where .= " AND home_work_history_id='{$conditions['home_work_history_id']}' ";
				}

				if(!empty($conditions['chapter_id'])){
					$where .= " AND chapter_id='{$conditions['chapter_id']}' ";
				}

				if(!empty($conditions['uid'])){
					$where .= " AND uid='{$conditions['uid']}' ";
				}

				if(!empty($conditions['subject_id'])){
					$where .= " AND subject_id='{$conditions['subject_id']}' ";
				}
			}
			$sql = "SELECT topic_id,user_answers,is_right,fraction,topic_type FROM {$this->db->dbprefix}tk_test_topic_historys $where ";
			$result = $this->db->query($sql)->result_array();
			return  $result;
		}
	}
